package com.mall.pojo;

import cn.hutool.core.util.DesensitizedUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mall.Enum.Sex;
import com.mall.note.Sensitize;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author xiao-chen
 * @since 2023-04-20
 */
@Data
@TableName("t_user")
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 用户名
     */

    private String username;
    /**
     * 用户真实名
     */
    @Sensitize(type = DesensitizedUtil.DesensitizedType.CHINESE_NAME)
    private String trueName;
    /**
     * 密码
     */
    @Sensitize(type = DesensitizedUtil.DesensitizedType.PASSWORD)
    private String password;


    /**
     * 性别
     */
    @TableField("sex")
    private Sex sex;

    /**
     * 电话
     */
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
    @NotNull
    @Sensitize(type = DesensitizedUtil.DesensitizedType.MOBILE_PHONE)
    private String phone;

    /**
     * 邮箱
     */
    @Email(message = "邮箱格式不正确")
    @Sensitize(type = DesensitizedUtil.DesensitizedType.EMAIL)
    private String email;


    /**
     * 上次登录时间
     */
    private LocalDateTime loadDate;
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createDate;
    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateDate;
    /**
     * 修改人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;
    /**
     * 创建人
     */
    @TableField(fill = FieldFill.INSERT)
    private Long createUser;
    /**
     * 用户状态 0禁用1正常
     */
    private Integer status;
}
